home *** CD-ROM | disk | FTP | other *** search
- /*******************************************************************************
- * Copyright © 1992-1993 Mark Pilgrim *
- * *
- * This file is provided as is, and may be freely distributed unaltered. This *
- * message must accompany any copy of this file. This file may be used or *
- * modified for use for a non-commercial product provided that appropriate *
- * credit is given to the author named above. *
- * Commercial use of this source code is prohibited. *
- ******************************************************************************/
-
- #include "msg misc.h"
- #include "msg timing.h"
-
- #define BlockSize 10
- #define CorrectTime 6
-
- void FourCornerCentered(GrafPtr);
-
- /* Really, this only uses one region and one CopyBits per round. Regions don't
- have to be continuous. On each axis, on each side of the center of the screen,
- there are two parts of the region which move towards different corners. */
-
- void FourCornerCentered(GrafPtr sourceGrafPtr)
- {
- RgnHandle curregion;
- Rect source;
- int cx,cy,lastx,lasty,VBlockSize;
-
- cx = MAIN_WINDOW_WIDTH / 2;
- cy = MAIN_WINDOW_HEIGHT / 2;
- VBlockSize=BlockSize*MAIN_WINDOW_HEIGHT/MAIN_WINDOW_WIDTH;
-
- curregion=NewRgn();
- source.top=source.left=0;
- source.bottom=MAIN_WINDOW_HEIGHT;
- source.right=MAIN_WINDOW_WIDTH;
-
- lasty=lastx=0;
- do
- {
- StartTiming();
- SetEmptyRgn(curregion);
- MoveTo(cx,cy);
- OpenRgn(); /* much much faster than 8 regions/CopyBits */
- LineTo(cx-lastx,0);
- Line(-BlockSize,0);
- LineTo(cx+lastx+BlockSize,MAIN_WINDOW_HEIGHT);
- Line(-BlockSize,0);
- LineTo(cx,cy);
-
- LineTo(cx+lastx,0);
- Line(BlockSize,0);
- LineTo(cx-lastx-BlockSize,MAIN_WINDOW_HEIGHT);
- Line(BlockSize,0);
- LineTo(cx,cy);
-
- LineTo(MAIN_WINDOW_WIDTH,cy-lasty);
- Line(0,-VBlockSize);
- LineTo(0,cy+lasty+VBlockSize);
- Line(0,-VBlockSize);
- LineTo(cx,cy);
-
- LineTo(MAIN_WINDOW_WIDTH,cy+lasty);
- Line(0,VBlockSize);
- LineTo(0,cy-lasty-VBlockSize);
- Line(0,VBlockSize);
- LineTo(cx,cy);
- CloseRgn(curregion);
-
- CopyBits(&(sourceGrafPtr->portBits), &(gMainWindow->portBits),
- &source, &source, 0, curregion);
- lastx+=BlockSize;
- lasty+=VBlockSize;
- TimeCorrection(CorrectTime);
- }
- while (lastx<cx);
-
- CopyBits(&(sourceGrafPtr->portBits), &(gMainWindow->portBits),
- &source, &source, 0, 0L); /* in case we miss a few pixels */
-
- DisposeRgn(curregion);
- }
-